package flst.ipiweb.service;

import java.util.ArrayList;
import java.util.List;

import flst.ipiweb.common.Article;
import flst.ipiweb.dao.DAOFactory;
import flst.ipiweb.exceptions.IPIWebException;

public class ServiceArticle {

	public List<Article> listerArticles(){
		
		try {
			return DAOFactory.getArticleDAO().listerArticles();
		} catch (IPIWebException e) {
			return new ArrayList<Article>();
		}
	}
	
	public Article getArticleById(int idArticle){
		
		try {
			return DAOFactory.getArticleDAO().getArticleById(idArticle);
		} catch (IPIWebException e) {
			return new Article();
		}
	}

	public void deleteArticle(Article article){
	
		try {
			 DAOFactory.getArticleDAO().deleteArticle(article);
		} catch (IPIWebException e) {
			
		}
	}
	
	public void createArticle(Article article){
		
		try {
			 DAOFactory.getArticleDAO().createArticle(article);
		} catch (IPIWebException e) {
			
		}
	}
	
	public List<Article> rechercheArticleByRef(String refArticle){
		try {
			return DAOFactory.getArticleDAO().rechercheArticleByRef(refArticle);
		} catch (IPIWebException e) {
			return new ArrayList<Article>();
		}
      }

      public List<Article> rechercheArticleByPrice(String price){
    	  try {
  			return DAOFactory.getArticleDAO().rechercheArticleByPrice(price);
  		} catch (IPIWebException e) {
  			return new ArrayList<Article>();
  		}
      }

      public List<Article> rechercheArticleByDescription(String description){
    	  try {
  			return DAOFactory.getArticleDAO().rechercheArticleByDescription(description);
  		} catch (IPIWebException e) {
  			return new ArrayList<Article>();
  		}
      }
      
      /*public int creerReference(){
    	  try {
  			return DAOFactory.getArticleDAO().creerReference();
  		} catch (IPIWebException e) {
  			return new INT();
  		}
      } */

      public void majArticle(Article article){
    	  try {
  			DAOFactory.getArticleDAO().majArticle(article);
  		} catch (IPIWebException e) {
  		
  		}
      } 
      
}
